<?php
namespace app\models;

use yii\base\Model;
use yii\web\NotFoundHttpException;
/**
 * 学生界面：修改密码表单
 * @author Administrator
 *
 */
class PasswordAlertForm extends Model
{
	public $pwd;//原密码

	public $newpwd;//新密码
	public $renewpwd;//重复输入新密码
	
	public function rules()
	{
		return [
				[['pwd','renewpwd','newpwd'], 'required'],
				[['pwd','renewpwd','newpwd'], 'string', 'min' => 6],
				['renewpwd','compare','compareAttribute'=>'newpwd','message'=>'两次输入的密码不一致。'],
		];
		
	}
	
	public function attributeLabels(){
		return [
				'pwd'=>'原密码',
				'newpwd'=>'新密码',
				'renewpwd'=>'新密码确认',
				
		];
	}
	
	public function uppwdtohash(){
		$this->pwd=\Yii::$app->getSecurity()->generatePasswordHash($this->pwd);
		return true;
	}
}